nums = [1,3,5,6]
target=7
def searchInsert(nums,target):
    left,right=0,len(nums)-1
    while left<=right:
        #求中间值
        # mid=int(((right-left)+1)/2)
        mid=(right+left)>>1
        # print(mid)
        if nums[mid]==target:
            return mid
        elif nums[mid]>target:
            right=mid-1
        else:
            left=mid+1
    return left

print(searchInsert(nums,target))